TABLE.CREATE_BEGIN Function

Syntax

V Create_Begin(C Fieldname,C Fieldtype[,N Field_Width[, N Field_Decimal[,C flags]]])

Arguments

FieldnameCharacter

The name of the field.

FieldtypeCharacter

The field types, the single character codes used to represent them, and the valid parameters associated with them are:

Field Type
Type Code and Valid Parameters
Bitmap

"B", Fieldname, Field Type

Character

"C", Fieldname, Field Type, Width

Date

"D", Fieldname, Field Type

Exponent Numeric

"E", Fieldname, Field Type

Linked image

"I", Fieldname, Field Type

JPEG

"J", Fieldname, Field Type

Logical

"L", Fieldname, Field Type

Memo

"M", Fieldname, Field Type

Numeric

"N", Fieldname, Field Type, Width , Decimal Width

OLE

"O", Fieldname, Field Type

Rich text memo

"R", Fieldname, Field Type

Time

"T", Fieldname, Field Type

Short Time

"Y", Fieldname, Field Type

Field_WidthNumeric

The number of characters (including any decimal characters) to allocate to the field. Available if Field_Type is "C" or "N".

Field_DecimalNumeric

The number of characters after the decimal point. Only available if Field_Type is "N".

flagsCharacter

Additional flags.

Description

Start defining a new Table, defines the first field.

Discussion

The TABLE.CREATE_BEGIN() method is used together with the TABLE.FIELD_ADD() and TABLE.CREATE_END() methods to define and create a new table file. The first field of the table is defined in TABLE.CREATE_BEGIN(). Subsequent fields are then defined using TABLE.FIELD_ADD(). When the table definition is complete, use TABLE.CREATE_END() to actually create and open the table file.

A field definition consists of at least two parameters, the Field_Name and Field_Type, and can contain up two optional parameters, Width and Decimal_Width. Field_Type is a string containing a single-character code representing one of the field types.

The chosen field type determines how the optional parameters are used. If the Field_Type is Character, an additional Width parameter is supplied, and if the Field Type is Numeric, the additional Width and optional Decimal Width parameters are specified. Date, Memo, Rich text memo, Bitmap, OLE, and Logical fields are always defined with two parameters because the field widths for these field types are set automatically.

Example

Create a table.

table.create_begin("firstname","c",30)
table.field_add("lastname","c",30)
table.field_add("price","n",5,2)
table.field_add("quantity","n",2)
table.field_add("birthday","d")
'The create_end() method creates the table and assign an object pointer to the table
tbl = table.create_end("c:\sample.dbf")

' optionally get the fully qualified name of the new table and add it to the workspace
newtable = tbl.filename_get()
file_add_to_db(newtable)
tbl.close()

See Also